package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 生命值低于60%时净化自身，并附加【暴雨梨花】，只能触发一次/n无冷却时间
 */
public class 梨花PH extends PassiveHandler {

	private int 血量;

	private int buff;

	//血量=6000&buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量 = args.getInt("血量", 0);
		buff = args.getInt("buff", 0);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量 += args.getInt("血量", 0);
	}

	private boolean settle;

	@Override
	public void onMoveDone(MoveCtx move, TimeActionCtx action) {
		settleAddBuff(action);
	}

	@Override
	public void onResurrect(ActionCtx action) {
		settleAddBuff(action);
	}

	private void settleAddBuff(ActionCtx action) {
		if (settle) {
			return;
		}
		if (skill.owner.isDead()) {
			return;
		}
		if (skill.owner.attr.total().hpCurRate() > 血量) {
			return;
		}
		skill.owner.buff.tryDispelBad(action);
		skill.owner.buff.tryAddByTid(action, buff);
		settle = true;
	}
}
